package net.haiyue.api.repository;
import net.haiyue.api.entity.Project;
import net.haiyue.api.entity.SelectInfo;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;



@Transactional
public interface ProjectRepository extends BaseRepository<Project,Integer> {
    @Query(value = "SELECT  DISTINCT id as value,name as label FROM projects",nativeQuery = true)
    List<SelectInfo> selectProject();

    @Query(value = "SELECT DISTINCT  P.name AS label,P.id As value FROM projects P LEFT JOIN modules M ON P.id=M.pid LEFT " +
            "JOIN rmu R ON M.id=R.mid WHERE R.uid=?1",nativeQuery = true)
    List<SelectInfo> selectFilterProject(int id);
}

